Silence log message when trying to unregister a watch that's already been
authorEwan Mellor <ewan@xensource.com>
Wed, 29 Nov 2006 12:14:45 +0000 (12:14 +0000)
committerEwan Mellor <ewan@xensource.com>
Wed, 29 Nov 2006 12:14:45 +0000 (12:14 +0000)
unregistered -- this is not a problem.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/xenstore/xswatch.py

index e84fe83ba9a9cf510d61a4727ac65a6827c20dc7..a1ea740a94c557edca976519c1cd70a8fdef7d31 100644 (file)
@@ -5,6 +5,7 @@
 # Public License.  See the file "COPYING" in the main directory of
 # this archive for more details.
 
+import errno
 import threading
 from xen.xend.xenstore.xsutil import xshandle
 
@@ -65,7 +66,15 @@ def watchMain():
             watch = we[1]
             res = watch.fn(we[0], *watch.args, **watch.kwargs)
             if not res:
-                watch.unwatch()
+                try:
+                    watch.unwatch()
+                except RuntimeError, exn:
+                    if exn.args[0] == errno.ENOENT:
+                        # The watch has already been unregistered -- that's
+                        # fine.
+                        pass
+                    else:
+                        raise
         except:
             log.exception("read_watch failed")
             # Ignore this exception -- there's no point throwing it